package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 条件查询购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 根据购物车id更新数据
     * @param shoppingCart
     */
    void updateCartById(ShoppingCart shoppingCart);

    /**
     * 新增数据
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id = #{currentId}")
    void clearShoppingCart(Long currentId);


    @Delete("delete from shopping_cart where id = #{id}")
    void deleteDishOrSetmealById(ShoppingCart shoppingCart);

    /**
     * 批量插入数据
     * @param shoppingCartList
     */
    void batchInsert(List<ShoppingCart> shoppingCartList);
}
